package com.atguigu.spring5.jdbctemplate.dao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

@Repository
public class AccountDaoImpl implements AccountDao{
    @Autowired
    private JdbcTemplate jdbcTemplate;

    @Override
    public void addMoney() {
        String sql = "update t_account set money=money+? where user_name=?";
        jdbcTemplate.update(sql,100,"mary");
        System.out.println("mary 账户添加了100");
    }

    @Override
    public void reduceMoney() {
        String sql = "update t_account set money=money-? where user_name=?";
        jdbcTemplate.update(sql,100,"lucy");
        System.out.println("lucy 账户减少了100");
    }
}
